package com.etc.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.entity.Customer;
import com.etc.service.CustomerService;
import com.etc.service.impl.CustomerServiceImpl;

@WebServlet("/update")
public class UpdateCustomerServlet extends HttpServlet{
	private CustomerService CustomerService =new CustomerServiceImpl();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	update(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	doGet(req, resp);
}
private void update(HttpServletRequest request, HttpServletResponse response)  throws IOException, ServletException{
//System.out.println(1);
String nickname=request.getParameter("nickname");
String mobile=	request.getParameter("mobile");
String password=request.getParameter("password");

//System.out.println(nickname);	
//System.out.println(mobile);	
//System.out.println(password);	
int id=1; //从登录的人获取它的主键id
int i=	CustomerService.update(nickname,mobile,password,id);
Customer customer=	CustomerService.search(id);
request.setAttribute("customer", customer);
request.getRequestDispatcher("/about?op=find").forward(request, response);
}
}
